/*
 * (C) 2014-2015 Alibaba Group Holding Limited
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 *
 *     __  ___   ______        ___       __          ___
 *    |  |/  /  /  __  \      /   \     |  |        /   \
 *    |  '  /  |  |  |  |    /  ^  \    |  |       /  ^  \
 *    |    <   |  |  |  |   /  /_\  \   |  |      /  /_\  \
 *    |  .  \  |  `--'  |  /  _____  \  |  `----./  _____  \
 *    |__|\__\  \______/  /__/     \__\ |_______/__/     \__\
 *
 *
 *
 */
//
// Created by KOALA TEAM on 12/19/14.
//

#import <UIKit/UIKit.h>


#ifndef KLROUTER


#define KLGotoVCWithURL(url) \
[[KLRouter sharedInstance] open:url] \

#define KLGotoVC(viewControllerName, paramDict) \
[[KLRouter sharedInstance] gotoViewController:viewControllerName withParams:paramDict]

#define KLGotoVC2(viewController) \
[[KLRouter sharedInstance] gotoViewController:viewController]


#define KLReplaceVC(viewController,viewControllerName, paramDict) \
[[KLRouter sharedInstance] replace:viewController WithViewController:viewControllerName withParams:paramDict]

#define KLReplaceVC2(srcViewContrller,dstViewContrller) \
[[KLRouter sharedInstance] replace:srcViewContrller WithDstViewController:dstViewContrller]


#define KLCreateVC(viewControllerName, paramDict) [KLRouter createViewController:viewControllerName withParams:paramDict]


#define KLDismissVC(viewController) [[KLRouter sharedInstance] dismissViewController:viewController]

#endif


@interface KLRouter : NSObject

/**
 * gets singleton object.
 * @return singleton
 */

+ (KLRouter*)sharedInstance;

//viewController: or initWithParams:

+ (UIViewController*)createViewController:(NSString*)viewControllerName withParams:(NSDictionary*)params;


- (void) dismissViewController:(UIViewController *)viewController;
- (BOOL) open:(NSString*)urlStr;
- (BOOL) handleUrl:(NSURL*)url;
- (UIViewController *)createViewController:(Class)vcCls params:(NSDictionary *)params;

- (void) gotoViewController:(NSString *)viewControllerName withParams:(NSDictionary *)params;
- (void) gotoViewController:(UIViewController *)viewController;
- (void) replace:(UIViewController*)viewController WithViewController:(NSString *)viewControllerName withParams:(NSDictionary *)params;
- (void) replace:(UIViewController*)srcViewController WithDstViewController:(UIViewController *)dstViewController;



@end
